﻿<Window x:Class="WindowPlace.WindowInfoDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:local="clr-namespace:WindowPlace"
        xmlns:WPCommon="clr-namespace:WindowPlace.Common"
        Title="Edit WindowInfo" SizeToContent="WidthAndHeight"
        MinWidth="300">
    <Window.CommandBindings>
        <CommandBinding Command="Close" Executed="Close_Executed"></CommandBinding>
        <CommandBinding Command="Save" Executed="Save_Executed"></CommandBinding>
        <CommandBinding Command="{x:Static local:MainWindow.SetToCurrentPositionCommand}"
                        Executed="SetToCurrentPosition_Executed"
                        CanExecute="SetToCurrentPosition_CanExecute"></CommandBinding>
    </Window.CommandBindings>
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibility"></BooleanToVisibilityConverter>
        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="CaptionFilterTypes">
            <ObjectDataProvider.MethodParameters>
                <x:Type xmlns="clr-namespace:WindowPlace.Common" TypeName="StringFilterTypeEnum" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <Style TargetType="TextBlock" x:Key="PropertyStyle">
            <Setter Property="HorizontalAlignment" Value="Right"></Setter>
            <Setter Property="Margin" Value="2,2,10,2"></Setter>
        </Style>
        <Style TargetType="TextBox" x:Key="ValueStyle">
            <Setter Property="HorizontalAlignment" Value="Left"></Setter>
            <Setter Property="Margin" Value="10,2,10,2"></Setter>
        </Style>
    </Window.Resources>
    <DockPanel LastChildFill="True" Margin="3">
        <StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom"
                    HorizontalAlignment="Right"
                    Margin="0,5,0,0">
            <Button Padding="2" IsCancel="True" Margin="0,0,10,0"
                    Command="ApplicationCommands.Close">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/WindowPlace;component/icons/bt_delete.png" Height="15"></Image>
                    <TextBlock Text="Cancel" VerticalAlignment="Center" Margin="5,2"></TextBlock>
                </StackPanel>
            </Button>
            <Button Padding="2" IsDefault="True"
                    Command="ApplicationCommands.Save">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/WindowPlace;component/icons/bt_apply.png" Height="15"></Image>
                    <TextBlock Text="Close" VerticalAlignment="Center" FontWeight="Bold" Margin="5,2"></TextBlock>
                </StackPanel>
            </Button>
        </StackPanel>

        <TextBlock Text="{Binding WindowInfo.hWnd, StringFormat='hWnd: {0}'}" DockPanel.Dock="Bottom"
                   FontWeight="Bold" Margin="1"></TextBlock>
        <StackPanel DockPanel.Dock="Top">
            <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2">
                <Image HorizontalAlignment="Right" VerticalAlignment="Center" Width="15" ToolTip="Window is Found"
                            Visibility="{Binding WindowInfo.IsFound, Converter={StaticResource BoolToVisibility}}" 
                            Source="/WindowPlace;component/icons/ball_green.png"
                       ></Image>
                <Image HorizontalAlignment="Right" VerticalAlignment="Center" Width="15"
                       ToolTip="Window not Found"
                            Visibility="{Binding WindowInfo.IsNotFound, Converter={StaticResource BoolToVisibility}}" 
                            Source="/WindowPlace;component/icons/ball_red.png"></Image>
                <TextBlock Text="{Binding WindowInfo.Caption}" FontSize="12" FontWeight="Bold" 
                           MaxWidth="500" TextWrapping="Wrap" HorizontalAlignment="Left"
                               VerticalAlignment="Center" Margin="10,2"></TextBlock>
            </StackPanel>
            <GroupBox Header="Caption Filter" DataContext="{Binding WindowInfo}" Padding="2">
                <StackPanel>
                    <TextBox Text="{Binding CaptionFilter}" Margin="0,2" FontWeight="Bold" FontStyle="Italic"></TextBox>
                    <ComboBox SelectedItem="{Binding CaptionFilterType}"
                              ItemsSource="{Binding Source={StaticResource CaptionFilterTypes}}"></ComboBox>
                </StackPanel>
            </GroupBox>
            <GroupBox Header="Startup" Padding="2" DataContext="{Binding WindowInfo}">
                <StackPanel>
                    <CheckBox IsChecked="{Binding AllowStartup}" Margin="1">Allow Startup</CheckBox>
                    <TextBox Text="{Binding StartupArguments}" Margin="1" MaxWidth="350">
                        <TextBox.ToolTip>
                            <TextBlock >Startup Arguments</TextBlock>
                        </TextBox.ToolTip>
                    </TextBox>

                    <TextBox Text="{Binding ModuleFullFilename, Mode=TwoWay}" DockPanel.Dock="Bottom" TextWrapping="Wrap"
                                MaxWidth="350" TextAlignment="Left" Margin="1">
                        <TextBox.ToolTip>
                            <TextBlock >ModuleFullFilename</TextBlock>
                        </TextBox.ToolTip>
                    </TextBox>
                </StackPanel>
            </GroupBox>
            <GroupBox Header="Position and Size" Padding="2"
                      Visibility="{Binding IsEditing, Converter={StaticResource BoolToVisibility}}">
                <Grid DataContext="{Binding WindowInfo}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="22"></RowDefinition>
                        <RowDefinition Height="22"></RowDefinition>
                        <RowDefinition Height="22"></RowDefinition>
                        <RowDefinition Height="22"></RowDefinition>
                        <RowDefinition Height="22"></RowDefinition>
                        <RowDefinition Height="32"></RowDefinition>
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Column="0" Grid.Row="0" Text="Ignore Placement &amp; Size" Style="{StaticResource PropertyStyle}"></TextBlock>
                    <TextBlock Grid.Column="0" Grid.Row="1" Text="Top" Style="{StaticResource PropertyStyle}"></TextBlock>
                    <TextBlock Grid.Column="0" Grid.Row="2" Text="Left" Style="{StaticResource PropertyStyle}"></TextBlock>
                    <TextBlock Grid.Column="0" Grid.Row="3" Text="Width" Style="{StaticResource PropertyStyle}"></TextBlock>
                    <TextBlock Grid.Column="0" Grid.Row="4" Text="Height" Style="{StaticResource PropertyStyle}"></TextBlock>

                    <CheckBox Grid.Column="1" Grid.Row="0" IsChecked="{Binding IgnorePlacementAndSize}" Margin="2"></CheckBox>
                    <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Top, Mode=TwoWay}" Style="{StaticResource ValueStyle}"></TextBox>
                    <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Left, Mode=TwoWay}" Style="{StaticResource ValueStyle}"></TextBox>
                    <TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding Width}" HorizontalAlignment="Left" Margin="10,2"></TextBlock>
                    <TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding Height}" HorizontalAlignment="Left" Margin="10,2"></TextBlock>

                    <Button Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" Margin="10,3" Padding="2"
                             HorizontalAlignment="Stretch"
                            IsEnabled="{Binding IsFound}"
                            Command="{x:Static local:MainWindow.SetToCurrentPositionCommand}"
                            CommandParameter="{Binding }">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WindowPlace;component/icons/computer.png" Width="15"></Image>
                            <TextBlock Text="Get Current Position" VerticalAlignment="Center" FontWeight="Bold" Margin="5,1"></TextBlock>
                        </StackPanel>
                    </Button>
                </Grid>
            </GroupBox>
        </StackPanel>
    </DockPanel>
</Window>
